﻿using System;
using System.Runtime.CompilerServices;

namespace eLoop;

public sealed class DefaultQueueSchedulerAllotter : ADefaultAllotter
{
    public DefaultQueueSchedulerAllotter(bool syncContext) : this(Environment.ProcessorCount * 2, syncContext)
    {
    }

    public DefaultQueueSchedulerAllotter(int count, bool syncContext)
    {
        this.Schedulers = new ITaskScheduler[count];
        for (int i = 0; i < this.Schedulers.Length; i++)
        {
            this.Schedulers[i] = Scheduler.CreateQueueScheduler(syncContext);
        }
    }

    protected override ITaskScheduler[] Schedulers
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get;
    }
}